<?php
function genVerify($data){
//    $new_data = allVerify($data);
    ksort($data);
    $items = array();
    foreach ($data as $key => $value) {
        if(is_array($value)){
            $items[] = genVerify($value);
        }else{
            $items[] = $key.$value;
        }
    }
    return join('',$items);
}

function alert_json_new($flag,$tip,$data=[]){
    echo json_encode(array('flag'=>$flag,'tip'=>$tip,'data'=>$data));
    exit;
}
function push($url,$post_data){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT,60);//单位秒,也可以使用
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
    $output = curl_exec($ch);
    curl_close($ch);
    return trim($output,'﻿');//替换掉utf8 BOM格式编码字符
}

function push_all($url,$post_data){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT,60);//单位秒,也可以使用
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_data));
    $output = curl_exec($ch);
    curl_close($ch);
    return trim($output,'﻿');//替换掉utf8 BOM格式编码字符
}
function total_tax($total_price,$ems_fee,$insure_amount,$consumption_rate,$increment_rate,$discount_rate=0.7){
    $wan_fee=$total_price+$ems_fee+$insure_amount;//完税价格
    $consumption_fee=$wan_fee/(1-$consumption_rate)*$consumption_rate*$discount_rate;//消费税
    if($consumption_rate>0){
        $increment_fee=$wan_fee/(1-$consumption_rate)*$increment_rate*$discount_rate;
    }else{
        $increment_fee=($wan_fee+$consumption_fee)*$increment_rate*$discount_rate;
    }
    
    return $consumption_fee+$increment_fee;
}